//
//  HLTzhanneixinTableViewController.m
//  huiliantong
//
//  Created by hlt on 15/9/16.
//  Copyright (c) 2015年 hlt. All rights reserved.
//

#import "HLTzhanneixinTableViewController.h"
#import "HLxiaoxizhongxiTTableViewController.h"
@interface HLTzhanneixinTableViewController ()

@end

@implementation HLTzhanneixinTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    
    self.xiaoxi1.clipsToBounds=YES;
//    self.xiaoxi1.layer.masksToBounds=YES;
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0) {
        
        
        
        HLxiaoxizhongxiTTableViewController *vc=[[HLxiaoxizhongxiTTableViewController alloc]init];
        vc.type=indexPath.row;
        [self.navigationController pushViewController:vc animated:NO];
        
    }
    
    
    
    
    
}




-(void) viewWillAppear:(BOOL)animated
{
    
    
    
    UIView *view1=[[UIView alloc] initWithFrame:self.view.bounds];
    view1.backgroundColor=[UIColor grayColor];
    view1.alpha=0.4;
    [self.view addSubview:view1];
    MONActivityIndicatorView *indicatorView = [[MONActivityIndicatorView alloc] init];
    indicatorView.delegate = self;
    indicatorView.numberOfCircles = 3;
    indicatorView.radius = 20;
    indicatorView.internalSpacing = 3;
    indicatorView.center = self.view.center;
    [indicatorView startAnimating];
    [self.view addSubview:indicatorView];
    
    Account *acc=[[AccountTool sharedAccountTool]currentAccount];
    NSString *url=[jianchazhanneixin stringByAppendingFormat:@"&username=%@",acc.custPhone];
    //将url转换一下格式，否则请求的格式就不兼容
    //    url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
    [HLTNetWorkingtool getdic:url success:^(NSDictionary *ary) {
        //        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        //        NSString *str = [numberFormatter stringFromNumber:ary[@"11"]];
        //
        
        [indicatorView stopAnimating];
        [view1 removeFromSuperview];
        
        if ([ary count]>0) {
            
        
        NSArray *keyary=[ary allKeys];
        int num=0;
        //通过下面这个循环得到消息总数
        for (int i=0; i<[keyary count]; i++) {
            
            
            NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
                    NSString *str1 = [numberFormatter stringFromNumber:ary[keyary[i]]];
            NSString *str=[NSString stringWithFormat:@" %@ ",str1];
            
            if ([keyary[i] isEqual:@"0"]) {
                
                self.xiaoxi1.text=str;
                 self.xiaoxi1.hidden=NO;
            }else if ([keyary[i] isEqual:@"1"])
            {
                 self.xiaoxi2.text=str;
                 self.xiaoxi2.hidden=NO;
            }else if ([keyary[i] isEqual:@"2"])
            {
                 self.xiaoxi3.text=str;
                 self.xiaoxi3.hidden=NO;
            }else if ([keyary[i] isEqual:@"3"])
            {
                 self.xiaoxi4.text=str;
                 self.xiaoxi4.hidden=NO;
            }else if ([keyary[i] isEqual:@"4"])
            {
                 self.xiaoxi5.text=str;
                 self.xiaoxi5.hidden=NO;
            }else if ([keyary[i] isEqual:@"5"])
            {
                 self.xiaoxi6.text=str;
                 self.xiaoxi6.hidden=NO;
            }else if ([keyary[i] isEqual:@"6"])
            {
                 self.xiaoxi7.text=str;
                 self.xiaoxi7.hidden=NO;
            }else if ([keyary[i] isEqual:@"7"])
            {
                 self.xiaoxi8.text=str;
                 self.xiaoxi8.hidden=NO;
            }else if ([keyary[i] isEqual:@"8"])
            {
                 self.xiaoxi9.text=str;
                self.xiaoxi9.hidden=NO;
            }else if ([keyary[i] isEqual:@"9"])
            {
                 self.xiaoxi10.text=str;
                 self.xiaoxi10.hidden=NO;
            }else if ([keyary[i] isEqual:@"10"])
            {
                 self.xiaoxi11.text=str;
                 self.xiaoxi11.hidden=NO;
            }else if ([keyary[i] isEqual:@"11"])
            {
                 self.xiaoxi12.text=str;
                 self.xiaoxi12.hidden=NO;
            }else if ([keyary[i] isEqual:@"12"])
            {
                 self.xiaoxi13.text=str;
                 self.xiaoxi13.hidden=NO;
            }
            
            
            
            
            
            num+=[ary[keyary[i]] intValue];
        }
        }
    } faliure:^(NSString *error) {
        [indicatorView stopAnimating];
        [view1 removeFromSuperview];
    }];
    
    
    
    
}




//这个是回调方法
#pragma mark - MONActivityIndicatorViewDelegate Methods

- (UIColor *)activityIndicatorView:(MONActivityIndicatorView *)activityIndicatorView
      circleBackgroundColorAtIndex:(NSUInteger)index {
    CGFloat red   = (arc4random() % 256)/255.0;
    CGFloat green = (arc4random() % 256)/255.0;
    CGFloat blue  = (arc4random() % 256)/255.0;
    CGFloat alpha = 1.0f;
    return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
}









@end
